package ${packagePath}.impl;

import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ibp.core.service.impl.BaseServiceImpl;
import ${packagePath}.${simpleName};

<#if imports??>
<#list imports as import>
import ${import};
</#list>
</#if>
import javax.annotation.Resource;
import java.util.List;

/**
 * ${comment}
 * @date ${.now?string("yyyy-MM-dd HH:mm:ss")}
 * @author ${author}
 */
@Log4j2
@Service
public class ${simpleName}Impl extends BaseServiceImpl implements ${simpleName} {

    @Resource
    private ${simpleMapper} ${lowerSimpleMapper};

    /**
     * 查询列表数据
     * @param ${dao.lowerModelName} 入参
     * @return 数据结果集
     */
    @Override
    public List<${dao.modelName}> getList(${dao.modelName} ${dao.lowerModelName}){
        return ${lowerSimpleMapper}.findList(${dao.lowerModelName});
    }

    /**
     * 查询分页数据
     * @param ${dao.lowerModelName} 入参
     * @return 数据结果集
     */
    @Override
    public PageInfo<${dao.modelName}> getPage(${dao.modelName} ${dao.lowerModelName}){
        Page<${dao.modelName}> page = PageHelper.getLocalPage();
        PageInfo<${dao.modelName}> pageInfo = page.toPageInfo();
        List<${dao.modelName}> list = ${lowerSimpleMapper}.findPageList(${dao.lowerModelName});
        pageInfo.setList(list);
        return pageInfo;
    }

<#list dao.model.fields as field>
    <#if field.id>
    /**
     * 新增数据
     * @param ${dao.lowerModelName} 入参
     */
    @Override
    public void addData(${dao.modelName} ${dao.lowerModelName}){
        ${lowerSimpleMapper}.insert(${dao.lowerModelName});
    }

    /**
     * 根据主键查询数据
     * @param ${field.name} 主键ID
     * @return 数据结果集
     */
    @Override
    public ${dao.modelName} getDataById(${field.typeSimpleName} ${field.name}){
        return ${lowerSimpleMapper}.findById(${field.name});
    }

    /**
     * 更新数据
     * @param ${field.name} 主键ID
     * @param ${dao.lowerModelName} 入参
     */
    @Override
    public void updateData(${field.typeSimpleName} ${field.name}, ${dao.modelName} ${dao.lowerModelName}){
        ${lowerSimpleMapper}.update(${field.name}, ${dao.lowerModelName});
    }

    /**
     * 根据主键删除数据
     * @param ${field.name} 主键ID
     */
    @Override
    public void deleteDataById(${field.typeSimpleName} ${field.name}){
        ${lowerSimpleMapper}.deleteById(${field.name});
    }

    </#if>
</#list>

}